/**
 * @author hewei
 * @version 1.0
 * @description: 1094. 拼车
 * @date 2022/10/29 16:06
 */

public class CarPooling {

    public boolean carPooling(int[][] trips, int capacity) {
        int[] count = new int[10001];
        for (int[] trip : trips) {
            int sum = trip[0];
            for (int i = trip[1]; i < trip[2]; i++) {
                count[i] += sum;
                if (count[i] > capacity) return false;
            }
        }
        return true;
    }
}
